package com.me.libgdx_test;

//Looking back on this, I prob should have made ClassAbstractDungeonObject 
//and ClassAbstractObjectDungeon a bit different 
public class ClassDungeonShop extends AbstractClassDungeonObject{
	String[] upgrade_string;
	boolean upgradeable;
	String shop_image;
	int tech_level;
	int price;
	boolean purchased;
	boolean actual_shop;
	int upgrade_id;
	private ClassLogDisplay logger;
	
	ClassDungeonShop(String Name, String shop_image, String Image, String Description, 
			String Advice,String[] upgrade_string, int tech_level, boolean actual_shop){
		logger = new ClassLogDisplay("ClassDungeonShop");
		this.Name = Name;
		this.shop_image = shop_image;
		this.Image = Image;
		this.Description = Description;
		this.Advice = Advice;
		this.upgrade_string = upgrade_string;
		this.tech_level = tech_level;
		this.actual_shop = actual_shop;
		this.purchased = false;
		//logger.print("Name: " + this.Name);
		//logger.print("Tech Level: " + this.tech_level);
		if(this.upgrade_string.length>0){
			upgradeable = true;
			this.Name = upgrade_string[this.tech_level] + " " + this.Name;
			this.Description = get_level_description(this.tech_level,false);
		}else{
			upgradeable = false;
		}
		unlock_cost = get_unlock_cost();
		price = 0;
	}
	ClassDungeonShop(ClassDungeonShop shop){
		Name = shop.Name;
		shop_image = shop.shop_image;
		Image = shop.Image;
		Description = shop.Description;
		Advice = shop.Advice;
		upgrade_string = shop.upgrade_string;
		tech_level = shop.tech_level;
		actual_shop = shop.actual_shop;
		purchased = shop.purchased;
		upgradeable = shop.upgradeable;
		price = shop.price;
		unlock_cost = shop.unlock_cost;
	}
	public ClassUnlockCost get_unlock_cost(){
		return new ClassUnlockCost(tech_level+1);
	}
	public void set_price(int initial_price){
		price = initial_price;
		if(upgradeable){
			price = (int)(initial_price + (float)initial_price * ((float)(tech_level+1))/10);
		}
	}
	public void set_tech_level(int tech_level){
		this.tech_level = tech_level;
		Description = get_level_description(this.tech_level, true);
	}
	public String get_shop_image(){
		return shop_image;
	}
	public String get_level_description(int tech_level, boolean info){
		String Description = "";
		if(Name.contains("Shield")){
			if(info){
				Description += "(Purchased) ";
			}
			Description += "Immune to: ";
			if(tech_level==10){
				Description += "Poison, ";
			}
			if(tech_level>7){
				Description += "Amnesia, ";
			}
			if(tech_level>4){
				Description += "Mana Burn, ";
			}
			if(tech_level>2){
				Description += "Weakness, ";
			}
			if(tech_level<=2){
				Description += "Blind";
			}else{
				Description += "and Blind";
			}
		}	
		if(Name.contains("Armor")){
			if(info){
				Description += "(Purchased) ";
			}
			Description += "Increases Physical Defense by: " + (int)((.025f * (tech_level+1))*100) + "%";
		}
		if(Name.contains("Helm")){
			if(info){
				Description += "(Purchased) ";
			}
			Description += "Increases Magical Defense by: " + (int)((.025f * (tech_level+1))*100) + "%";
		}
		if(Name.contains("Boots")){
			if(info){
				Description += "(Purchased) ";
			}
			Description += "Increases Player Evade by: " + (int)((.015f * (tech_level+1))*100) + "%";
		}
		if(Name.contains("Gloves")){
			if(info){
				Description += "(Purchased) ";
			}
			Description += "Increases Shroud Regen Rate by: " + (int)(tech_level == 10?4:tech_level/3);
		}
		if(Name.contains("Staff")){
			if(info){
				Description += "(Purchased) ";
			}
			Description += "Increases Magic Attack by: " + (int)((.025f * (tech_level+1))*100) + "%";
		}
		if(Name.contains("Sword")){
			if(info){
				Description += "(Purchased) ";
			}
			Description += "Increases Physical Attack by: " + (int)((.025f * (tech_level+1))*100) + "%";
		}
		if(Name.contains("Mace")){
			if(info){
				Description += "(Purchased) ";
			}
			Description += "Increases Double Hit Chance by: " + (int)((.025f * (tech_level+1))*100) + "%";
		}
		if(Name.contains("Dice")){
			if(info){
				Description += "(Purchased) ";
			}
			Description += "Increases Attack Range Upper Bounds by: " + (int)((.25f * (tech_level+1))*100) + "%";
		}
		if(Name.contains("Scope")){
			if(info){
				Description += "(Purchased) ";
			}
			if(tech_level==10){
				Description += "Allows player to see through shroud";
			}else{	
				Description += "Allows player to see: ";
				if(tech_level>7){
					Description += "Enemies, ";
				}
				if(tech_level>4){
					Description += "Spells, ";
				}
				if(tech_level>2){
					Description += "Shops, ";
				}
				if(tech_level<=2){
					Description += "Items";
				}else{
					Description += "and Items";
				}
			}
		}
		if(Name.contains("Mining")){
			Description += "(Permanent) ";
			Description += "Increases Gold Piles by: " + (int)(1f * (tech_level+1));
		}
		if(Name.contains("Refining")){
			Description += "(Permanent) ";
			Description += "Increases Gold Value by: " + (int)(1f * (tech_level+1));
		}
		if(Name.contains("Medicine")){
			Description += "(Permanent) ";
			Description += "Increases Potions Effectiveness by: " + (int)((.05f * (tech_level+1))*100) + "%";
		}
		if(Name.contains("Barter")){
			Description += "(Permanent) ";
			Description += "Increases Shop Discount by: " + (int)((.05f * (tech_level+1))*100) + "%";
		}
		if(Name.contains("Cities")){
			Description += "(Permanent) ";
			Description += "Increases Shop/Altar Frequency by: " + (int)((.25f * (tech_level+1))*100) + "%";
		}
		if(Name.contains("Religion")){
			Description += "(Permanent) ";
			Description += "Decreases Piety Needed by: " + (int)((.05f * (tech_level+1))*100) + "%";
		}
		if(Name.contains("Ritual")){
			Description += "(Permanent) ";
			Description += "Increases Starting HP/MP by: " + (int)(1f * (tech_level+1));
		}
		return Description;
	}
	public double two_decimals(double number){
		return Math.round(number * 100.000) / 100.000;
	}
}
